package com.HomeWorkhsp.Chapter08.homework.homework00;

/**
 * Enjoy programming!!!
 * Time: 2022/1/9 -  23:36
 */
class Person {
    private String name;
    private int age;
    private String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }
//    public Person (){}
    public String toString(){
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", job='" + job + '\'' +
                "}";




    }
}

public class HomeWork00 {
    public static void main(String[] args) {
        Person[] arr = new Person[3];
        arr[0] = new Person("jack", 18, "boss");
        arr[1] = new Person("tom", 52, "php工程师");
        arr[2] = new Person("smith", 30, "java架构师");

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

        Person person = null;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[i].getAge() > arr[i + 1].getAge()) {
                    person = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = person;
                }
            }

        }
        System.out.println("排序之后的结果：");
        for (int i = 0; i < 3; i++) {
            System.out.println(arr[i]);
        }
    }
}

